package com.example.demo.web;

import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.dao.UserDao;
import com.example.demo.entity.SysUser;


@RestController
@RequestMapping("/zongJingLiActiviti")
public class ZongJingLiActiviti {

	private Logger logger = LoggerFactory.getLogger(ZongJingLiActiviti.class);
	
	@Autowired
	private UserDao userDao;
	@Autowired
	private TaskService taskService;
	
	
	private SysUser zongJingLi(){
		String ZhuoJunWu = "b6930e157bac4a12b6ffb97a976e95cc";
		SysUser sysUser = userDao.findById(ZhuoJunWu).get();
		return sysUser;
	}
	
	@RequestMapping(value = "doActiviti")
	public String doActiviti(){
		Task task = taskService.createTaskQuery().taskAssignee(zongJingLi().getName()).list().get(0);
		String id = task.getId();
		System.out.println("ID:.===>"+id);
		taskService.complete(id);
		System.out.println("------任务审批完成-------");
		return "流程结束";
	}
}
